package com.tanhua.domain.mongo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 * 点赞 喜欢 评论
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(collection = "comment")
public class Comment implements java.io.Serializable{

    private static final long serialVersionUID = -291788258125767614L;

    private ObjectId id;

    private ObjectId publishId;    //发布id 有可能是圈子动态 有可能是小视频 也有可能是评论
    private Integer commentType;   //评论类型，1-动态点赞，2-动态评论，3-动态喜欢 4-视频点赞  5-视频评论  6-评论点赞
    private String content;        //评论内容
    private Long userId;           //评论人
    private Integer likeCount = 0; //点赞数对当前评论的点赞数
    private Long created; //发表时间

    private Long publishUserId; // 当前登录人评论、点赞、喜欢的是谁

    //动态选择更新的字段
    public String getCol() {
        return this.commentType == 1||this.commentType==4||this.commentType==6 ? "likeCount" : commentType==2||commentType==5? "commentCount"
                : "loveCount";
    }

    //动态选择返回圈子的字段
    public Integer getMovementCount(Movement movement) {
        return this.commentType == 1? movement.getLikeCount() : commentType==2? movement.getCommentCount()
                : movement.getLoveCount();
    }
}